package com.briup.jz.web.controller;

import com.briup.jz.bean.AccountCustomer;
import com.briup.jz.bean.extend.AccountCustomerExtend;
import com.briup.jz.dao.AccountCustomerMapper;
import com.briup.jz.service.IAccountCustomerService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/customer")
@Api(description = "客户账号管理接口")
public class AccountCustomerController {
    @Autowired
    private IAccountCustomerService accountCustomerService;
    @Resource
    private AccountCustomerMapper accountCustomerMapper;

    @ApiOperation("查询所有客户操作")
    @GetMapping("query")
    public Message query(Double transfer_money, String type, String status, Long userId) {
        List<AccountCustomer> list = accountCustomerService.query(transfer_money, type, status, userId);
        return MessageUtil.success(list);
    }
    @ApiOperation("级联查询所有客户操作")
    @GetMapping("queryCascade")
    public Message queryCascade(Double transfer_money, String type, String status, Long userId) {
        List<AccountCustomerExtend> list = accountCustomerService.queryCascade(transfer_money, type, status, userId);
        return MessageUtil.success(list);
    }
 
    //保存货更新客户信息
    @ApiOperation("保存或更新客户信息")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate( AccountCustomer customer) {
        accountCustomerService.saveOrupdate(customer);
        return MessageUtil.success("更新成功");

    }
    @ApiOperation(value = "通过id删除顾客信息")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
        accountCustomerService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}